{% extends "admin/base_site.html" %}
{% load i18n static admin_urls bootstrap_admin_template_tags %}

{% block extrahead %}{{ block.super }}
  <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
{% endblock %}

{% block extrastyle %}
  {{ block.super }}
  <link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />
{% endblock %}

{% block bodyclass %}{{ block.super }} {{ opts.app_label }}-{{ opts.model_name }} change-form{% endblock %}

{% if not is_popup %}
  {% block breadcrumbs %}
    <ol class="breadcrumb">
      <li class="home">
        <a href="{% url 'admin:index' %}" title="{% trans 'Home' %}"><span class="glyphicon glyphicon-home"></span></a>
      </li>
      <li>
        <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a>
      </li>
      <li>
        <a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>
      </li>
      <li>
        <a href="{% url opts|admin_urlname:'change' original.pk|admin_urlquote %}">{{ original|truncatewords:"18" }}</a>
      </li>
      <li>
        {% trans 'Change password' %}
      </li>
    </ol>
  {% endblock %}
{% endif %}

{% block content %}
  <div id="content-main">
    <form action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %}
      <div>
        {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
        {% if form.errors %}
          <p class="alert alert-danger">
            {% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
          </p>
        {% endif %}

        <div class="panel panel-default">
          <div class="panel-heading">
            {% blocktrans with username=original %}Enter a new password for the user <strong>{{ username }}</strong>.{% endblocktrans %}
          </div>
          <div class="panel-body">
            <fieldset class="module aligned">
              <div class="row">
                <div class="col-sm-6{% if form.password1.errors %} has-error{% endif %}">
                  {% for error in form.password1.errors %}
                    <p class="help-block error">{{ error }}</p>
                  {% endfor %}
                  {# TODO: get required class on label_tag #}
                  <label for="id_password1" class="required">{% trans 'Password' %}:</label> {{ form.password1|add_class:'form-control' }}
                </div>

                <div class="col-sm-6{% if form.password2.errors %} has-error{% endif %}">
                  {% for error in form.password2.errors %}
                    <p class="help-block error">{{ error }}</p>
                  {% endfor %}
                  {# TODO: get required class on label_tag #}
                  <label for="id_password2" class="required">{% trans 'Password (again)' %}:</label> {{ form.password2|add_class:'form-control' }}
                  <p class="help">{% trans 'Enter the same password as above, for verification.' %}</p>
                </div>
              </div>
            </fieldset>
            <hr>
            <div class="submit-row">
              <input type="submit" value="{% trans 'Change password' %}" class="default btn btn-primary" />
            </div>
          </div>
        </div>

        <script type="text/javascript">document.getElementById("id_password1").focus();</script>
      </div>
    </form>
  </div>
{% endblock %}
